
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <!-- 设置页面的 基本路径，页面所有资源引入和页面的跳转全部基于 base路径 -->
    <base href="<%=basePath%>">
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,permission-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="/favicon.ico" >
    <link rel="Shortcut Icon" href="/favicon.ico" />

    <script type="text/javascript" th:src="@{/lib/html5shiv.js}"></script>
    <script type="text/javascript" th:src="@{/lib/respond.min.js}"></script>


    <link rel="stylesheet" type="text/css" th:href="@{/h-ui/css/H-ui.min.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/h-ui.admin/css/H-ui.admin.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/lib/Hui-iconfont/1.0.8/iconfont.css}" />
    <link rel="stylesheet" type="text/css"th:href="@{/h-ui.admin/skin/default/skin.css}" id="skin" />
    <link rel="stylesheet" type="text/css"th:href="@{/h-ui.admin/css/style.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/lib/bootstrap/css/bootstrap.css}" />
    <link rel="stylesheet" type="text/css" th:href="@{/lib/bootstrap-table/bootstrap-table.css}" />


    <script type="text/javascript" th:src="@{/lib/DD_belatedPNG_0.0.8a-min.js}" ></script>
    <script>DD_belatedPNG.fix('*');</script>

    <title>添加权限-权限管理</title>
</head>
<body>
<article class="page-container">
    <form class="form form-horizontal"  action="/logistics/permission/saveOrUpdate"   method="post" id="form-admin-add">
        <input type="hidden" name="permissionId" th:value=" ${permission != null} ? ${permission.permissionId}">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>权限名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text"  class="input-text"  th:value=" ${permission != null} ? ${permission.name}"  placeholder="" id="name" name="name">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">权限类型：</label>
            <div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
			<select class="select"  name="type" size="1">
				<option value="menu" th:selected="${permission != null} ? ${permission.type eq 'menu'}" >菜单权限</option>
				<option value="permission" th:selected="${permission != null} ? ${permission.type eq 'permission'}">普通权限</option>
			</select>
			</span> </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>权限地址：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text"  th:value=" ${permission != null} ?${permission.url}"  id="url" name="url">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>权限表达式：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text"  th:value=" ${permission != null} ?${permission.expression}"  id="expression" name="expression">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">父权限名：</label>
            <div class="formControls col-xs-8 col-sm-9"> <span class="select-box" style="width:150px;">
			<select class="select"  name="parentId" size="1">
				<option value="">菜单权限</option>
<!--                <option th:each="pName:${pNames}" th:selected="${pName != null} ? (${permission.parentId} eq ${pName.permissionId})" th:value="${pName.permissionId}" th:text="${pName.name}"></option>-->
                <option th:each="pName:${pNames}"  th:value="${pName.permissionId}" th:text="${pName.name}"></option>
			</select>
			</span> </div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" th:src="@{/lib/jquery/1.11.3/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{/lib/jquery.validation/1.14.0/jquery.validate.js}"></script>
<script type="text/javascript" th:src="@{/lib/jquery.validation/1.14.0/messages_zh.js}"></script>
<script type="text/javascript" th:src="@{/lib/jquery.validation/1.14.0/validate-methods.js}"></script>
<script type="text/javascript" th:src="@{/lib/layer/2.4/layer.js}"></script>
<script type="text/javascript" th:src="@{/h-ui/js/H-ui.min.js}"></script>
<script type="text/javascript" th:src="@{/h-ui.admin/js/H-ui.admin.js}"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" th:src="@{/lib/My97DatePicker/4.8/WdatePicker.js}"></script>
<script type="text/javascript" th:src="@{/lib/datatables/1.10.0/jquery.dataTables.min.js}"></script>
<script type="text/javascript" th:src="@{/lib/bootstrap-table/bootstrap-table.js}"></script>
<script type="text/javascript" th:src="@{/lib/bootstrap-table/bootstrap-table-zh-CN.min.js}"></script>

<script type="text/javascript">
    $(function(){
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form-admin-add").validate({
            rules:{
                name:{
                    required:true
                },
                type:{
                    required:true
                },
                expression:{
                    required:true
                }
            },
            success:"valid",
            messages:{
                name:{
                    required:"权限名称不能为空"
                },
                type:{
                    required:"请选择"
                },
                expression:{
                    required:"权限表达式不能为空"
                }
            },
            submitHandler:function(form) {

                $(form).ajaxSubmit(function (data) {
                    layer.msg(data.msg,{icon: data.code,time:1000},function () {
                        //操作成功刷新数据
                        if (data.code == 1){

                            //刷新父页面表格
                            parent.refresh();
                            //关闭窗口
                            parent.layer.closeAll();

                        }
                    });

                });

            }
        });
    });

</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>